﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TBFramework;
using System;
using StandardStorage;
public class LocalMethod : StandardMethod
{
    [HideInInspector]
    public StandardClass standardClass;

    public Dictionary<string,Action<UnityEngine.Object>> localMethodActions = new Dictionary<string, Action<UnityEngine.Object>>();
    protected void Init()
    {
        standardClass = new StandardClass("test");
        StartCoroutine(standardClass.StartRunAsyncMethod(standardClass));
/*
        GlobalStorageClass globalStorageClass = new GlobalStorageClass();
        globalStorageClass.globalMethodActions.Add ("test", (T) => { Debug.Log((T as Transform).transform.name); });
        
        GlobalStorageClass.GlobalMethodDelegate<Transform, string> globalMethodDelegate = (T) => { return (T as Transform).transform.name; };
        globalMethodDelegate+=(T) => { return (T as Transform).transform.name; };

        StandardProperty.Instance.cameraStruct.isOpen = true;
        StandardProperty.Instance.cameraStruct.mouseActions = new List<Action<Transform>>();


        StandardProperty.Instance.cameraStruct.isControlCamera = true;
        StandardProperty.Instance.cameraStruct.isOpenCloseCameraControl = true;

       MethodCollection<Transform> methodCollection = new MethodCollection<Transform>(5);
        methodCollection[0, "dd"] = (Transform T) =>
        {
            print("sdfsdf");
        };
        
        StepCurrentProperty stepCurrentProperty = new StepCurrentProperty();
        stepCurrentProperty.step1 = new step1Struct();
        stepCurrentProperty.step1.value1 = 222;

        IECollection<StepCurrentProperty> ieCollection = new IECollection<StepCurrentProperty>(5);
        ieCollection[0, "dd"] = step1(stepCurrentProperty);
        StartCoroutine(ieCollection["dd"]);

      localMethodActions.Add("test", (T) => { Debug.Log((T as Transform).transform.name); });
       StandardProperty.Instance.cameraStruct.mouseActions.Add(methodCollection["dd"]);

       StandardProperty.Instance.cameraStruct.mouseActions.Add(methodCollection["dd"]);
       StandardProperty.Instance.cameraStruct.mouseActions.Remove(methodCollection["dd"]);   


         StandardProperty.Instance.UICamera.isOpen = true;
         StandardProperty.Instance.UICamera.uiMouseActions = new List<Action<Transform>>(); 
         StandardProperty.Instance.UICamera.uiMouseActions.Add((T) => { Debug.Log(T.transform.name); });
*/
         //StandardProperty.Instance.minMaxWindows.isOpen = false;

        base.UIObjectsAddDrag();
        StandardProperty.Instance.RefreshActions.Add(() => { Refresh(); base.UIPositioning(); });
    }
    // Update is called once per frame
    protected void Refresh()
    {
        if (StandardProperty.Instance.cameraStruct.isOpen)
        {
            MainCameraRayControl(StandardProperty.Instance.cameraStruct.mainCamera,StandardProperty.Instance.cameraStruct.distance,StandardProperty.Instance.cameraStruct.layerMask,StandardProperty.Instance.cameraStruct.mouseActions);
        } 
        if (StandardProperty.Instance.UICamera.isOpen)
        {
            UiCameraRayControl(StandardProperty.Instance.UICamera.MiniMap,StandardProperty.Instance.UICamera.uiCamera,StandardProperty.Instance.UICamera.distance,StandardProperty.Instance.UICamera.layerMask,StandardProperty.Instance.UICamera.uiMouseActions,StandardProperty.Instance.UICamera.uiCameraControl,StandardProperty.Instance.UICamera.canvas);
        }
        if (StandardProperty.Instance.followUI.isOpen)
        {
            StandardProperty.Instance.followUI.followUI.gameObject.SetActive(true);
            UIFollowMouse(StandardProperty.Instance.followUI.followUI,StandardProperty.Instance.followUI.offsetState,StandardProperty.Instance.UICamera.MiniMap,StandardProperty.Instance.UICamera.uiCamera,StandardProperty.Instance.UICamera.canvas);
        }
        else
        {
            StandardProperty.Instance.followUI.followUI.gameObject.SetActive(false);
        }
    }
}
